package com.hm.pagejump.slice;

import com.hm.pagejump.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.components.Text;
import ohos.agp.components.element.ShapeElement;

public class PictureSelectSlice extends AbilitySlice {
    private Text text;
    private Button button;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_picture_select);

        text = (Text)findComponentById(ResourceTable.Id_text_picture_select);
        if (intent != null){
           String stringParam = intent.getStringParam("jump_key");
            text.setText(stringParam);
        }

        button = (Button)findComponentById(ResourceTable.Id_button_picture_select_finish);
        ShapeElement element = new ShapeElement();
        element.setRgbColor(new RgbColor(100,123,120));
        button.setBackground(element);
        button.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent intent_picture_select = new Intent();
                intent_picture_select.setParam("picture_resource_id", 10001);
                setResult(intent_picture_select);
                terminate();
            }
        });
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
